package com.cheyun.netsalev3.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;


import com.bumptech.glide.Glide;
import com.cheyun.netsalev3.R;
import com.m4399.gridviewlayout.GridViewLayout;

public class ImageGridAdapter extends GridViewLayout.GridViewLayoutAdapter<String, PicListHolder> {
	public ImageGridAdapter(Context context)
	{
		super(context);
	}

	@Override
	protected int getItemLayoutID() {
		return R.layout.item_image;
	}

	@Override
	protected PicListHolder onCreateView(View itemView)
	{
		return new PicListHolder(getContext(), itemView);
	}

	@Override
	protected void onBindView(PicListHolder view, int position)
	{
		view.bindView(getData().get(position));
	}
}

class PicListHolder extends GridViewLayout.GridViewLayoutViewHolder
{
	private ImageView image;

	private Context context;

	public PicListHolder(Context context, View itemView)
	{
		super(context, itemView);
		this.context = context;
	}

	@Override
	protected void initView()
	{
		image = findViewById(R.id.imageView);

	}

	public void bindView(String pic)
	{
		Glide.with(context).load(pic).into(image);
	}
}